<template>

    <Header @log-register="login_register" v-if="!(store.state.admin)"></Header> <!--    头部导航栏-->
    <br>
    <br>
    <br>
    <router-view></router-view>

    <Sidebar></Sidebar>  <!--    侧边栏-->

    <WebInfo></WebInfo>  <!--    底部网站信息-->

    <PopUps></PopUps> <!--    全局弹窗-->

    <UserInformation v-if="store.state.user"></UserInformation> <!--    用户信息-->

    <UnreadMessages v-if="store.state.unread_messages"></UnreadMessages><!--   评论消息列表-->

    <LogRegister @shut-down="shutDown" v-if="logRegister" :kind="log_or_register" @handoff="handoff"></LogRegister> <!--    登录-->


</template>


<script setup>
import Header from "@/components/header/Header.vue";
import Sidebar from "@/components/publicComponent/Sidebar.vue";
import WebInfo from "@/components/publicComponent/WebInfo.vue";
import PopUps from "@/components/publicComponent/PopUps.vue";
import LogRegister from "@/components/publicComponent/LogRegister.vue";
import {onMounted, ref} from "vue";
import store from "@/store/index.js";
import UserInformation from "@/components/publicComponent/UserInformation.vue";
import UnreadMessages from "@/components/publicComponent/UnreadMessages.vue";


//是否显示登录注册窗口
const logRegister = ref(false);

//显示登录或注册默认显示登录
const log_or_register = ref(true);

//切换登录或注册
const handoff =(bool)=>{
    log_or_register.value = bool;
}

//打开登录注册窗口
const login_register = (bool)=>{
    logRegister.value = true;
    log_or_register.value = bool;
}
// 监听登录窗口关闭
const shutDown = ()=>{
    logRegister.value = false;
}

//预加载
onMounted(()=>{

    //初始化主题
    let topic =  window.localStorage.getItem("topic");
    if(topic){
        store.commit('globalStyles',topic);
    }

    let parse = JSON.parse(window.localStorage.getItem("user"));
    store.commit('user',parse);
})
</script>


<style scoped>

</style>
